package cn.com.chengmandian.bike.controller;


import cn.com.chengmandian.agent.utils.AuthUtil;
import cn.com.chengmandian.bike.constants.FaultBillDealCreateType;
import cn.com.chengmandian.bike.dto.FaultBillDealForm;
import cn.com.chengmandian.bike.service.IEbFaultBillDealService;
import cn.com.chengmandian.bike.service.IEbFaultBillInfoService;
import cn.com.chengmandian.core.web.pojo.AjaxResult;
import cn.com.chengmandian.core.web.utils.LocalMapUtil;
import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 电单车运营-订单问题工单-处理进度 前端控制器
 * </p>
 *
 * @author AutoGenerator
 * @since 2024-05-29
 */
@Api(tags = "订单问题工单-处理进度")
@RestController
@RequestMapping("/fault/bill/deal")
public class EbFaultBillDealController {

    @Autowired
    private IEbFaultBillDealService faultBillDealService;

    private IEbFaultBillInfoService faultBillInfoService;

    @ApiOperation("添加")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody FaultBillDealForm form) {
        Assert.notNull(form.getBillId(), "缺少工单ID");
        Assert.isTrue(StrUtil.isNotBlank(form.getContent()), "缺少内容");

        faultBillDealService.createRecord(form.getBillId(), FaultBillDealCreateType.MEMBER, form.getContent(), form.getImgUrl(), AuthUtil.getAgentUser());

        faultBillInfoService.sendNotice(LocalMapUtil.getAgentInfo(), form.getBillId(), "订单问题工单有新的处理进度，请及时查看", form.getImgUrl());

        return AjaxResult.success();
    }


}
